package observer;

import java.util.ArrayList;

/**
 * Created by simod on 2019/12/17
 */
public class Subject {
    private String state;
    private ArrayList<Observer> observers = new ArrayList<>();

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
        this.notice();
    }

    public void addObserver(Observer observer) {
        this.observers.add(observer);
    }


    public void notice() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}

